package com.ourteam.education.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ourteam.education.dao.ClassDefineDAOQueryBean;
import com.ourteam.education.domain.ClassDefineBean;
import com.ourteam.education.service.IClassDefineManageService;
import com.ourteam.frame.controller.AbstractCRUDServiceController;

@Controller
@CrossOrigin
@RequestMapping("/api/EDUCATION/classDefine")
public class ClassDefineManageAPI
		extends AbstractCRUDServiceController<ClassDefineDAOQueryBean, ClassDefineSearchBean, ClassDefineBean> {

	@Autowired
	private IClassDefineManageService classDefineService;

	@Override
	protected ClassDefineDAOQueryBean newQueryBean() {
		return new ClassDefineDAOQueryBean();
	}

	@Override
	protected int queryCount(ClassDefineDAOQueryBean queryBean) throws Exception {
		return classDefineService.queryClassCount(queryBean);
	}

	@Override
	protected ClassDefineBean[] queryData(ClassDefineDAOQueryBean queryBean) throws Exception {
		return classDefineService.queryClasss(queryBean);
	}

	@Override
	protected void deleteData(long[] ids) throws Exception {

		classDefineService.deleteClasss(ids);

	}

	@Override
	protected ClassDefineBean getDataById(long id) throws Exception {
		return classDefineService.getClassById(id);
	}

	@Override
	protected void saveData(ClassDefineBean dataBean) throws Exception {

		if (dataBean.getId() == 0) {
			classDefineService.addNewClass(dataBean);
		} else {
			classDefineService.modifyClass(dataBean);
		}
	}

}
